package com.oil.petro.eshop.bean;

import com.oil.petro.eshop.entity.Product;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

public class ProductBean extends BasicBean {

    @NotEmpty(message = "Pole nie może być puste")
    @Size(max = 100, message = "Za długa nazwa, maksymalnie {1} znaków")
    private String name;
    @NotEmpty(message = "Pole nie może być puste")
    @Size(max = 500, message = "Za długa nazwa, maksymalnie {1} znaków")
    private String description;
    @NotEmpty(message = "Pole nie może być puste")
    @Pattern(regexp = "\\d+\\.\\d{2}", message = "Nieprawidłowa wartość np.: 10.50")
    private String price;
    @NotEmpty(message = "Pole nie może być puste")
    @Pattern(regexp = "\\d+", message = "Nieprawidłowa wartość")
    private String amount;
    @NotEmpty(message = "Pole nie może być puste")
    private String manufacturerName;
    @NotEmpty(message = "Pole nie może być puste")
    private String categoryName;
    private CommonsMultipartFile image;
    private String tooltip;
    private String icon;
    private String file;
    //@NotEmpty(message = "Pole nie może być puste")
    //@Pattern(regexp = "\\d+", message = "Nieprawidłowa wartość")
    private String orderedQuantity;
    private int id;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public String getAmount() {
        return amount;
    }

    public void setAmount(String amount) {
        this.amount = amount;
    }

    public String getManufacturerName() {
        return manufacturerName;
    }

    public void setManufacturerName(String manufacturerName) {
        this.manufacturerName = manufacturerName;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

    public CommonsMultipartFile getImage() {
        return image;
    }

    public void setImage(CommonsMultipartFile image) {
        this.image = image;
    }

    public String getTooltip() {
        return tooltip;
    }

    public void setTooltip(String tooltip) {
        this.tooltip = tooltip;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public String getFile() {
        return file;
    }

    public void setFile(String file) {
        this.file = file;
    }

    public String getOrderedQuantity() {
        return orderedQuantity;
    }

    public void setOrderedQuantity(String orderedQuantity) {
        this.orderedQuantity = orderedQuantity;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public ProductBean(String tooltip, String icon, Product product) {
        this.name = product.getName();
        this.description = product.getDescription();
        this.price = product.getCost() + "";
        this.tooltip = tooltip;
        this.icon = icon;
        this.file = product.getImage();
        this.id = product.getId();
    }

    public ProductBean() {
    }

    @Override
    public String toString() {
        return "ProductBean{" + "name=" + name + ", description=" + description + ", price=" + price + ", amount=" + amount + ", manufacturerName=" + manufacturerName + ", categoryName=" + categoryName + ", image=" + image + ", tooltip=" + tooltip + ", icon=" + icon + '}';
    }

}
